<template>
  <div class="header">
    <div class="title">
      <span class="name">XXXX管理系统</span>
    </div>
    <div class="box">
      <div class="message">
        <el-badge :is-dot="isDot" class="item">
          <i class="el-icon-bell"></i>
        </el-badge>
      </div>
      <div class="personInfo">
        <el-dropdown @command="handleCommand">
          <div class="el-dropdown-link">
            <div class="img">
              <img src="../../assets/images/face.png" alt="">
            </div>
            <div class="doctor">
              <span>{{adminName}}</span><br>
              <span>{{adminDepartment}}-{{adminPosition}}</span>
            </div>
          </div>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item disabled>个人中心</el-dropdown-item>
            <el-dropdown-item @click="logout()" command="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Header",
  data() {
    return {
      isDot: true, // 是否显示有消息通知
      adminName: "",
      adminDepartment: "",
      adminPosition: ""
    };
  },
  created() {
    this.adminName = localStorage.getItem("adminName");
    this.adminDepartment = localStorage.getItem("adminDepartment");
    this.adminPosition = localStorage.getItem("adminPosition");
  },
  methods: {
    handleCommand(command) {
      if (command === "logout") {
        localStorage.clear();
        this.$router.push({ path: "/login" });
      }
    }
  }
};
</script>
<style lang="less" scoped>
@import "../../assets/theme/theme";
.header {
  position: absolute;
  top: 0;
  left: 0;
  height: 70px;
  width: 100%;
  min-width: 1366px;
  background-color: @headerBgc;
  display: flex;
  justify-content: space-between;
  padding: 0 50px;
  box-sizing: border-box;
  z-index: 2;
  .title {
    line-height: 70px;
    .name {
      font-size: 26px;
      font-weight: bold;
      letter-spacing: 5px;
      color: @headerName;
    }
    .hospital {
      font-size: 18px;
      font-weight: 400;
      color: @headerHospital;
    }
  }
  .box {
    display: flex;
    justify-content: flex-end;
    .message {
      padding: 0 30px;
      font-size: 20px;
      line-height: 35px;
      color: #fff;
      cursor: pointer;
      // 设置红点高度
      .el-badge {
        margin-top: 22px;
      }
    }
    .personInfo {
      cursor: pointer;
      .el-dropdown {
        margin-top: 14px;
        .el-dropdown-link {
          display: flex;
          justify-content: start-end;
          .img {
            width: 40px;
            height: 40px;
            border-radius: 20px;
            overflow: hidden;
            margin-right: 20px;
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }
          }
          .doctor {
            span {
              line-height: 20px;
              color: @headerInfo;
            }
          }
        }
      }
    }
  }
}
</style>
